import fetch from 'utils/fetch';

//2. 获取经销商的角色列表
export function getAgentRoleList() {
    return fetch({
        url: '/user/getAgentRoleList',
        method: 'post'
    });
}

//1. 分页获取经销商所有员工信息
export function findAgentUserByPage(account, userName, phone, roleId, page, row) {
    const data = {
        account,
        userName,
        phone,
        roleId,
        page,
        row
    };
    return fetch({
        url: `/user/findAgentUserByPage/${page}/${row}`,
        method: 'post',
        data
    });
}

//4. 根据员工ID获取员工信息

export function getAgentStaffInfo(id) {
    const data = {
        id
    };
    return fetch({
        url: '/user/getAgentStaffInfo',
        method: 'post',
        data
    });
}

//6. 更新经销商员工信息
export function updateAgentStaff(id, userName, phone, roleId, orgUserRegionMaps) {
    const data = {
        id,
        userName,
        phone,
        roleId,
        orgUserRegionMaps
    };
    return fetch({
        url: '/user/updateAgentStaff',
        method: 'post',
        data
    });
}

//3. 获取经销商代理区域信息列表
export function findAgentRegion() {
    return fetch({
        url: '/user/findAgentRegion',
        method: 'post'
    });
}

//5. 添加经销商员工信息
export function addAgentStaff(account, userName, password, confirmPassword, phone, roleId, orgUserRegionMaps) {
    const data = {
        account,
        userName,
        password,
        confirmPassword,
        phone,
        roleId,
        orgUserRegionMaps
    };
    return fetch({
        url: '/user/addAgentStaff',
        method: 'post',
        data
    });
}

//9. 初始化经销商员工密码为“111111”
export function initAgentStaffPasswd(id) {
    const data = {
        id
    }
    return fetch({
        url: '/user/initAgentStaffPasswd',
        method: 'post',
        data
    });
}

//8. 禁用经销商员工账号
export function inactiveAccount(id) {
    const data = {
        id
    };
    return fetch({
        url: '/user/inactiveAccount',
        method: 'post',
        data
    });
}

//7. 启用经销商员工账号
export function activeAccount(id) {
    const data = {
        id
    };
    return fetch({
        url: '/user/activeAccount',
        method: 'post',
        data
    });
}

// 修改密码
export function updatePassword(password, newPassword, confirmPassword) {
    const data = {
        password,
        newPassword,
        confirmPassword
    };
    return fetch({
        url: '/baseInfo/updatePassword',
        method: 'post',
        data
    });
}

// 原密码验证
export function validatePasswordLib(password) {
    const data = {
        password
    };
    return fetch({
        url: '/baseInfo/validatePassword',
        method: 'post',
        data
    });
}
